package org.jcc.core.cs.generic.container;

import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) {
		// =========================== generic way
		MyList<Integer> intList = new MyList<>();
		intList.add(1);// auto-boxing
		intList.add(2);
		
		int i1 = intList.get(0);
		int i2 = intList.get(1);
		
		MyList<String> strList = new MyList<>();
		strList.add("foo");
		strList.add("bar");
		
		String f = strList.get(0);
		String b = strList.get(1);
		
		// =========================== non generic way 
		List list = new ArrayList();
		
		// 放进去是 String
		list.add("a string");
		
		// 取出来就只能是 Object
		Object obj = list.get(0);
		
		// 或者需要强制类型转换
		String s = (String) list.get(0);
		
	}
}
